<template>
  <div class="index-map" style="height: calc(100vh - 64px)">
    <!-- <div class="indexLeft" style="margin-top:-40px;">
      <left-layout></left-layout>
    </div> -->

    <!-- <div class="indexRight" style="margin-top:-40px;">
      <right-layout-company v-if="showType === 'company'"></right-layout-company>
      <right-layout-station v-else></right-layout-station>
    </div> -->

    <div class="indexRight">
      <div class="events-container">
        <!-- <img src="../../assets/logincontainer.png" width="800px" height="1055px" /> -->
        <home-events-table> </home-events-table>
      </div>
    </div>

    <!-- <div class="charts-border indexNews">
      <scoll-news></scoll-news>
    </div> -->

    <Row type="flex" justify="start">
      <InMap class="mapHeight" @showInfo="showInfo"></InMap>
    </Row>
  </div>
</template>

<script>
import HomeEventsTable from "./homeEventsTable";
// 左侧布局
//import LeftLayout from "./leftLayout";
// 右侧布局tab
//import RightLayoutCompany from "./rightLayoutCompany";
//import RightLayoutStation from "./rightLayoutStation";
// 滚动新闻
//import ScollNews from "./centerLayout/scollNews";
// 背景地图
import { InMap } from "@/components/charts/map";
import { mapActions } from "vuex";
import Cookies from "js-cookie";

export default {
  name: "home",
  components: {
    HomeEventsTable,
    //LeftLayout,
    //RightLayoutCompany,
    //RightLayoutStation,
    //ScollNews,
    InMap
  },
  data() {
    return {
      contentHeight: "",
      showType: "company"
    };
  },
  methods: {
    ...mapActions(["handleLogOut"]),
    showInfo(name) {
      if (name === "陕西") {
        this.showType = "company";
      } else {
        this.showType = "station";
      }
    }
  },
  created() {
    // window.onload = () => {
    //异常关闭则为null
    if (window.sessionStorage.getItem("tempFlag_home") == null) {
      this.handleLogOut().then(() => {
        this.$router.push({
          name: "login"
        });
      });
      // location.reload(); //不能省，强制跳到登陆页
    }
    // };
  },
  mounted() {
    window.onload = () => {
      // window.onload = function() {
      // console.log("tempFlag:", window.sessionStorage.getItem("tempFlag_home"));
      if (window.sessionStorage.getItem("tempFlag_home") == "true") {
        window.sessionStorage.setItem("tempFlag_home", "false");
        // window.sessionStorage.removeItem("tempFlag");
        // console.log("tempFlag2:", window.sessionStorage.getItem("tempFlag_home"));
      }
      // else if (window.sessionStorage.getItem("tempFlag") == null) {
      //   console.log("tempFlag is null now");
      //   this.handleLogOut().then(() => {
      //     this.$router.push({
      //       name: "login"
      //     });
      //   });
      //   // location.reload(); //不能省，强制跳到登陆页
      // }
    };
    window.onunload = function() {
      window.sessionStorage.setItem("tempFlag_home", "true");
      // window.sessionStorage["tempFlag"] = true;
    };
    window.onbeforeunload = function() {
      window.sessionStorage.setItem("tempFlag_home", "true");
      // window.sessionStorage["tempFlag"] = true;
    };
  }
};
</script>

<style lang="less">
.indexChartsSize {
  width: 23vw;
  height: 27vh;
  z-index: 2;
}
.indexLeft {
  .indexChartsSize;
  position: absolute;
  top: 10%;
  left: 1%;
}
.events-container {
  position: absolute;
  right: -51%;
  //right: -235px;
  top: -10%;
  //top: -38px;
  z-index: 80;
  width: 800px;
  height: 1055px;
  //margin-top:-107px;
  //margin-right:30px;
  background: url(../../assets/logincontainer.png) no-repeat 0px 0px;
  background-size: 800px 1055px;
}
.indexRight {
  .indexChartsSize;
  position: absolute;
  top: 20%;
  right: 17%;
  margin-top: -110px;
}
.indexNews {
  position: absolute;
  bottom: 4%;
  left: 25%;
  right: 25%;
  z-index: 1000;
}
.mapHeight {
  height: 100%;
  width: 100%;
}
</style>
